import 'es6-promise/auto'
if (Number.parseInt === undefined) Number.parseInt = window.parseInt;
if (Number.parseFloat === undefined) Number.parseFloat = window.parseFloat;
import Vue from 'vue'
//  import VueSocketio from 'vue-socket.io';
// import { getToken } from '@/utils/auth'
/* if (getToken('session')) {
  Vue.use(new VueSocketio({
    debug: true,
    connection: 'ws://192.168.2.13:9999',
    /!* options: {
      'query': 'token=' + JSON.parse(getToken('session')).token + '&clientId=12&platform=1'
    }*!/
  }));
}*/
import 'normalize.css/normalize.css'// A modern alternative to CSS resets
import Element from 'element-ui'
import '@/assets/styles/index.scss' // global css
import App from './App'
import router from './router'
import store from './store'
import '@/assets/icons' // icon
import './permission' // permission control
import * as filters from './filters'
import ProcessLine from '@/components/ProcessLine/index'
import Download from '@/components/DownLoad/index'
import PreviewFile from '@/components/PreviewFile'
import CachedRouterView from '@/components/CachedRouterView/index'
import Table from '@/components/Table/index'
import TitleBadge from '@/components/TitleBadge'
import request from '@/utils/request'
import '@/utils/dialogDrag'// v-dialogDrag:弹窗拖拽+水平方向伸缩 贺凡 2021/03/12
import Contextmenu from 'vue-contextmenujs'// 右侧菜单 贺凡 2021/04/20
import UmyUi from 'umy-ui'// umy-ui 贺凡 2022/01/21
import 'umy-ui/lib/theme-chalk/index.css';// 引入样式 贺凡 2022/01/21

Vue.prototype.$request = request
// 按钮是否具有权限
const cache = store.state.jurisdiction.cache
function getPermission(e) {
  if (cache.indexOf(e) > -1) {
    return true
  }
  return false
}
// 表格操作宽度
function getColumnWidth(arr) {
  let width = 0
  for (let i = 0; i < arr.length; i++) {
    if (cache.indexOf(arr[i]) > -1) {
      width += 60
    }
  }
  return width
}
// :width="columnWidth(['updateSpecialCertificate','specialCertificateDetail','deleteSpecialCertificate'])"

//  v-if="permiBtn('updateMaintainLubricationPlan')"
Vue.prototype.permiBtn = getPermission
Vue.prototype.columnWidth = getColumnWidth
Vue.component('ProcessLine', ProcessLine);
Vue.component('Download', Download);
Vue.component('PreviewFile', PreviewFile);
Vue.component('CachedRouterView', CachedRouterView);
Vue.component('CommonTable', Table);
Vue.component('TitleBadge', TitleBadge);
Vue.use(Contextmenu);// 右侧菜单 贺凡 2021/04/20
Vue.use(UmyUi);// umy-ui 贺凡 2022/01/21
Element.Table.props.border = { type: Boolean, default: true };
Element.Table.props.stripe = { type: Boolean, default: true };
Vue.use(Element, {
  size: 'mini' // set element-ui default size
});
import echarts from '@/utils/echart/echartInit'
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
// location.hash = '/home'; // 刷新时候重置为首页
const vm = new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this// 安装全局事件总线，$bus就是当前应用的Vm
  }
})
window.vm = vm;
